threads.start(function () {
  
  //在新线程执行的代码
  while (true) {
      if (textContains("surebuybtn").findOne(1000)) {
          textContains("surebuybtn").click()
      }
      if (textContains("surebuybtn_new1").findOne(1000)) {
          textContains("surebuybtn_new1").click()
      }
      if (textContains("uphousesurebtn").findOne(1000)) {
          textContains("uphousesurebtn").click()
      }
      if (textContains("edayclosebtn").findOne(1000)) {
          textContains("edayclosebtn").click()
      }
      if (textContains("完成以下任务").findOne(1000)) {
          textContains("close").click()
      }
  }
}
)

while(1){
  while (!textContains("扫地机器人").findOne(5000)){
    click(100,960)
    sleep (1000)
    click(180,1620)
    sleep(5000)
  }
  sleep(20000)
  var closebtn = textContains("closestatbtn").find()
    if (closebtn.length >= 1) {
      
      for (var i = 0; i < closebtn.length; i++) {
       
        var str = closebtn[i].click()
       
      }
      log("家电已全部开启")
  }
  sleep(20000)
  while (textContains("close-btn").findOne(3000)){
    var close = textContains("close-btn").find()
    if (close.length >= 1) {
      
      for (var i = 0; i < close.length; i++) {
       
        var str = close[i].click()
        
      }
      log("弹窗页面已全部关闭")
  }
  sleep(20000)
  }
  
}